<blockquote>
    <p>Jms ActiveMq插件 @EnableActiveMQPlugin</p>
    <footer>
        <p><code>String brokerUrl</code>:  ActiveMq服务地址</p>
        <p><code>String username</code>: ActiveMq链接账号</p>
        <p><code>String password</code>: ActiveMq链接密码</p>
        <p>缺省配置</p>
        <p>#activemq</p>
        <p>ants.jms.activemq.broker-url=tcp://127.0.0.1:61616</p>
        <p>ants.jms.activemq.username=ants</p>
        <p>ants.jms.activemq.password=123456</p>
        <p>注解配置</p>
        @EnableActiveMQPlugin(brokerUrl="tcp://127.0.0.1:61616", username="ants", password ="123456")
    </footer>
</blockquote>
<blockquote>
    <p>使用ActiveMq时需要加入Maven依赖</p>
</blockquote>
<pre class="code brush:xml">
<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-core</artifactId>
    <version>5.7.0</version>
</dependency>
</pre>
<blockquote>
    <p>AtiveMq配置文件 <code>application.properties</code></p>
</blockquote>
<pre class="code brush:plain">
#redis

ants.jms.activemq.broker-url=tcp://127.0.0.1:61616

ants.jms.activemq.username=ants

ants.jms.activemq.password=123456
</pre>
<blockquote>
    <p>通过获取ActiveMqTpl对象, 发送消息</p>
    <footer style="color:red;">启动类必须要配置 @EnableActiveMQPlugin 注解</footer>
</blockquote>
<pre class="code brush:java">
package cn.jants.demos;


import cn.jants.common.annotation.action.Controller;
import cn.jants.common.annotation.action.GET;
import cn.jants.common.annotation.boot.PropertyConfiguration;
import cn.jants.common.annotation.plugin.EnableActiveMQPlugin;
import cn.jants.common.annotation.service.Application;
import cn.jants.common.annotation.service.Autowired;
import cn.jants.core.context.AppConfiguration;
import cn.jants.core.startup.JTomcat;
import cn.jants.plugin.jms.ActiveMqTpl;


/**
 * Tomcat 方式启动
 *
 * @author MrShun
 * @version 1.0
 * @Date 2017/12/20
 */
@Application
@PropertyConfiguration
@EnableActiveMQPlugin
@Controller
public class DemosApplication extends AppConfiguration {

    @Autowired
    private ActiveMqTpl activeMqTpl;


    @GET("/jms/send")
    public void get() {
        activeMqTpl.send("my.queue", "这是一条消息服务...");
    }

    public static void main(String[] args) {
        JTomcat.run(DemosApplication.class, 80, "/demo");
    }
}

</pre>
<blockquote>
    <p>示例 服务消费者Customer</p>
    <footer style="color:red;">必须要实现JmsCustomer接口</footer>
    <footer style="color:red;">必须指定队列名称 </footer>
</blockquote>
<pre class="code brush:java">
package cn.jants.demos.queue;

import cn.jants.plugin.jms.JmsConsumer;
import cn.jants.plugin.jms.JmsListener;

/**
 * 服务消费者
 * @author MrShun
 * @version 1.0
 */
@JmsListener(destination = "my.queue")
public class JmsProvider implements JmsConsumer {

    @Override
    public void received(String message) {
        System.out.println("确定消息已送达...");
    }
}
</pre>
<script type="text/javascript">
    $(function () {
        SyntaxHighlighter.highlight();
        $(".toolbar").remove();
    });
</script>